import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { GTabBar } from "../../../../com/mui/controls/GTabBar";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ObjCreate } from "../common/ObjCreate";
import { ArenaCrossMainPanel } from "./ArenaCrossMainPanel";
import { ArenaCrossBattlesPanel } from "./ArenaCrossBattlesPanel";
import { ArenaCrossTopListPanel } from "./ArenaCrossTopListPanel";
import { EArenaProcess } from "../../../../Message/Public/EArenaProcess";
import { PetHireInfoPanel } from "../petHire/PetHireInfoPanel";
import { PublicMessageConfig } from "../../resource/PublicMessageConfig";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SArenaCrossOpen } from "../../../../Message/Public/SArenaCrossOpen";
import { SMyArenaCrossInfo } from "../../../../Message/Public/SMyArenaCrossInfo";
import { SArenaCrossWaitingNum } from "../../../../Message/Public/SArenaCrossWaitingNum";
import { SArenaCrossToplists } from "../../../../Message/Public/SArenaCrossToplists";
import { SArenaMode } from "../../../../Message/Public/SArenaMode";
import { GButton } from "../../../../com/mui/controls/GButton";
import { SecTimerView } from "../common/SecTimerView";
type int = number;
//class ArenaCrossMainWindow
    
    export  class ArenaCrossMainWindow extends BaseWindow
    {
        constructor()
        {
            this._tabBarData = [{"label": Language.getString(44230), "name":"mainPanel"}, {"label": Language.getString(42233), "name":"seeList"}, {"label": Language.getString(44231), "name":"fristList"}];
            super();
            setSize(838, 555);
            titleHeight = 48;
            title = Language.getString(42234);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._tabBar = new GTabBar();
            this._tabBar.horizontalGap = 1;
            this._tabBar.buttonFilters = [FilterConst.glowFilter];
            this._tabBar.dataProvider = this._tabBarData;
            this._tabBar.buttonWidth = 75;
            ObjCreate.setObjAttri(this._tabBar, 23, 34, -1, -1, this);
            this._btnLookPrize = ObjCreate.createGButton(Language.getString(44257), 673, 33, 70, 22, this);
            this._btnHelp = ObjCreate.createGButton(Language.getString(42235), 750, 33, 70, 22, this, "Button");
            this._mainPanel = new ArenaCrossMainPanel();
            this._mainPanel.x = 18;
            this._mainPanel.y = 60;
            this.addChild(this._mainPanel);
            this._battlesPanel = new ArenaCrossBattlesPanel();
            this._battlesPanel.x = 18;
            this._battlesPanel.y = 60;
            this._firstListPanel = new ArenaCrossTopListPanel(EArenaProcess._EArenaElimination1);
            this._firstListPanel.x = 18;
            this._firstListPanel.y = 60;
            this._selectPanel = this._mainPanel;
            this._infoPanel = new PetHireInfoPanel();
            this._infoPanel.visible = false;
            this._infoPanel.x = 835;
            this._infoPanel.y = 40;
            var loc1=PublicMessageConfig.instance.getArenaTextByName("arenaCrossHelpDesc");
            this._infoPanel.updateByContent(loc1);
            this.addChild(this._infoPanel);
            this.addListeners();
            return;
        }

        /* internal  */addListeners(): void
        {
            this._tabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onTabChange);
            this._btnLookPrize.addEventListener(flash.events.MouseEvent.CLICK, this.onPrizeBtn);
            this._btnHelp.addEventListener(flash.events.MouseEvent.CLICK, this.onHelpBtn);
            return;
        }

        /* internal  */onTabChange(arg1: MuiEvent): void
        {
            var loc1=arg1.selectedIndex;
            var loc2=this.getPanelByIndex(loc1);
            if (this._selectPanel && this._selectPanel.parent) 
            {
                this._selectPanel.parent.removeChild(this._selectPanel);
            }
            this.addChild(loc2);
            this._selectPanel = loc2;
            return;
        }

        /* internal  */onPrizeBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShowKingWarModule));
            return;
        }

        /* internal  */onHelpBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._infoPanel.visible = !this._infoPanel.visible;
            return;
        }

        /* internal  */getPanelByIndex(arg1: int): Object /* flash.display.DisplayObject */
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case 0:
                {
                    return this._mainPanel;
                }
                case 1:
                {
                    return this._battlesPanel;
                }
                case 2:
                {
                    return this._firstListPanel;
                }
                default:
                {
                    return this._mainPanel;
                }
            }
        }

        public open(arg1: SArenaCrossOpen): void
        {
            this._mainPanel.resetOpenState(true);
            return;
        }

        public close(): void
        {
            this._mainPanel.resetOpenState(false);
            return;
        }

        public updateMyArenaCrossInfo(arg1: SMyArenaCrossInfo): void
        {
            this._mainPanel.updateMyArenaInfo(arg1);
            return;
        }

        public updateWaitingNum(arg1: SArenaCrossWaitingNum): void
        {
            return;
        }

        public updateTopList(arg1: SArenaCrossToplists): void
        {
            var loc1=null;
            if (this._tabBar.selectedIndex != 0) 
            {
                loc1 = this.getTopListPanelByProcess(arg1.process);
                if (loc1) 
                {
                    loc1.updateArenaCrossTopList(arg1);
                }
            }
            else 
            {
                this._mainPanel.updateArenaCrossTopData(arg1);
            }
            return;
        }

        /* internal  */getTopListPanelByProcess(arg1: int): ArenaCrossTopListPanel
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case 1: case 2: case 3: case 4:
                {
                    return this._firstListPanel;
                }
            }
            return null;
        }

        public updateBattles(arg1: Array<any>): void
        {
            this._battlesPanel.updateArenaCrossBattlesData(arg1);
            return;
        }

        public updateSignUpState(arg1: Boolean): void
        {
            this._mainPanel.updateSignUpState(arg1);
            return;
        }

        public set canSelectMode(arg1: SArenaMode)
        {
            return;
        }

        public updateWillOpenTime(): void
        {
            if (this._mainPanel) 
            {
                this._mainPanel.updateWillOpenTime();
            }
            return;
        }

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_selectPanel: Object /* flash.display.DisplayObject */;

        /* internal */ /* var */_tabBarData: Array<any>;

        /* internal */ /* var */_btnLookPrize: GButton;

        /* internal */ /* var */_btnHelp: GButton;

        /* internal */ /* var */_infoPanel: PetHireInfoPanel;

        /* internal */ /* var */_mainPanel: ArenaCrossMainPanel;

        /* internal */ /* var */_battlesPanel: ArenaCrossBattlesPanel;

        /* internal */ /* var */_firstListPanel: ArenaCrossTopListPanel;

        /* internal */ /* var */_timeView: SecTimerView;
    }
